import { defHttp } from '/@/utils/http/axios';
import {
  drivePageParams,
  comQueryParams,
  comPageQueryParams,
  comPageParams,
  BrandModel,
  DeviceTypeModel,
  ServiceModel,
  ServicePageParams,
  ServicePageListGetResultModel,
  ModelGroup, //添加物模型组
  DelModelGroup, //删除物模型组
  AddModelAttr, //添加物模型属性
  ModfiyModelAttr, //修改物模型属性
  QueryModelAttr, //查询物模型属性
  AddEquipment, //新增设备,
  ModifyEquipment, //修改设备
  GetEquipment, //查询设备
  DriveModel, //上传驱动
  SetdefaultdriveModel, //设置默认驱动
  selectdatalog,
  pushconfig,
  pushConfigModel,
  serviceEnableStatusModel,
} from '/@/extendModel/gatewayModel';
enum Api {
  GET_BRAND_BYID = '/brand/brand',
  GET_BRANDS = '/brand/brands',
  GET_DEVICE_TYPE = '/device_type/query_gateway_device_type',
  GET_DEVICE_MODE_ATTR_GROUP = '/device_mode/query_gateway_device_mode_attribute_group',
  ADD_UPDATE_DELETE_SERVICE = '/service/service', //创建、修改上云配置
  GET_SERVICE_LIST = '/service/services',
  GET_MODEl_LIST = '/device_mode/query_gateway_device_mode', //物模型列表
  ADD_DEVICE_MODE = '/device_mode/create_gateway_device_mode', //添加物模型
  UPDATE_DEVICE_MODE = '/device_mode/update_gateway_device_mode', //修改物模型
  DELETE_DEVICE_MODE = '/device_mode/delete_gateway_device_mode', //删除物模型
  ADD_MODEL_GROUP = '/device_mode/create_gateway_device_mode_attribute_group', //添加物模型组
  UPDATE_MODEL_GROUP = '/device_mode/update_gateway_device_mode_attribute_group', //修改物模型组
  GET_MODEL_GROUP = '/device_mode/query_gateway_device_mode_attribute_group', //获取物模型组
  DEL_MODEL_GROUP = '/device_mode/delete_gateway_device_mode_attribute_group', //删除物模型组
  ADD_MODEL_ATTRIBUTE = '/device_mode/create_gateway_device_mode_attribute', //添加物模型属性
  UPDATE_MODEL_ATTRIBUTE = '/device_mode/update_gateway_device_mode_attribute', //编辑物模型属性
  GET_MODEL_ATTRIBUTE = '/device_mode/query_gateway_device_mode_attribute', //获取物模型属性
  DEL_MODEL_ATTRIBUTE = '/device_mode/delete_gateway_device_mode_attribute', //删除物模型属性

  ADD_MAIN_EQUIPMENT = '/main/device/create_gateway_device', //添加主设备
  UPDATE_MAIN_EQUIPMENT = '/main/device/update_gateway_device', //修改主设备
  GET_MAIN_EQUIPMENT = '/main/device/query_gateway_device', //获取主设备
  DEl_MAIN_EQUIPMENT = '/main/device/delete_gateway_device', //删除主设备
  GET_NON_EQUIPMENT = '/device/query_gateway_non_main_device', //查询未被组合的新数据
  GET_MAIN_ONEEQUIPMENT = '/main/device/query_device', //查询一个设备详情

  ADD_EQUIPMENT = '/device/create_gateway_device', //添加子设备
  UPDATE_EQUIPMENT = '/device/update_gateway_device', //修改子设备
  GET_EQUIPMENT = '/device/query_gateway_device', //获取子设备
  DEl_EQUIPMENT = '/device/delete_gateway_device', //删除子设备

  IMPORT_MODEL_ATTRIBUTE = '/api/device_mode/upload_gateway_device_mode_attribute', //导入物模型属性
  CREAT_GATEWAY_DEVICE_TYPE = '/device_type/create_gateway_device_type', //添加型号
  UPDATE_GATEWAY_DEVICE_TYPE = '/device_type/update_gateway_device_type', //编辑型号
  DELETE_GATEWAY_DEVICE_TYPE = '/device_type/delete_gateway_device_type', //删除型号
  SET_DEFAULT_DEVICE_TYPE = '/device_type/set_default_drive_for_device_type', //设置默认驱动
  GET_DRIVE_LIST = '/drive/query_gateway_drive', //驱动列表
  UPLOAD_GATEWAY_DRIVE = '/api/drive/upload_gateway_drive', //上传驱动
  DOWNLOAD_GATEWAY_DRIVE = '/drive/download_drive_example', //下载驱动
  DELETE_GATEWAY_DRIVE = '/drive/delete_gateway_drive', //删除驱动
  ATTRTLTEDOWN = '/device_mode/download_attribute_excel_example', //属性模板导入下载
  GETDRIVEBYMODEID = '/drive/query_drive_by_mode', //根据物模型查询驱动
  QUERYDATALOG = '/log/query_gateway_data_log',
  PUTCONFIG = '/push/push', //获取或设置推送配置
  TESSTPUSH = '/push/test_push',
  synmodel = '/device_mode/sync_device_mode_info', //同步物模型
  modecloudinfoList = '/device_mode/list_device_mode_cloud_sync_info', //查询物模型云状态列表
  devicecloudList = '/device/list_device_cloud_sync_info', //查询设备云状态列表
  syndeviceinfo = '/device/sync_device_info', //同步设备
  serviceEnableStatus = '/service/service_enable_status', //更新云服务启用状态
  customsyncdevice = '/device/custom_sync_device_info', //自定义同步设备
  getDriveLog = '/log/query_connect_log', //获取驱动日志
  deviceModedata = '/device_mode/device_mode_data', //查询物模型数据
  gatewayoverview = '/statistics/gateway_overview', //网关总览
  flowtrend = '/statistics/flow_trend', //流量趋势
  devicequerydevice = '/device/query_device', //查询设备详情
  alarmcount = '/statistics/alarm_count', //过去20天报警推送次数
  attributedata = '/device_mode/attribute_data', //过去20天报警推送次数
  queryofflog = '/log/query_offline_log', //查询设备离线日志
  updateconfig = '/conf/update_config', //更新系统配置
  configoptionlist = '/conf/config_option_list', //系统配置列表
  resetgateway = '/user/restart_gateway', //重启网关
  getstanddrive = '/drive/query_standard_drives', //获取标准驱动
  getgatewaydrive = '/drive/query_gateway_drive', //获取自定义驱动
  updatemodelDrive = '/device_mode/update_gateway_device_drive_mode', //更新物模型和驱动
  creatmodelDrive = '/device_mode/create_device_mode_drive', //创建物模型和驱动
  singleDrive = '/drive/query_single_drive', //查询驱动详情
  hardwareinfo = '/statistics/hardware_info', //获取硬件信息
  inserttest = '/statistics/insert_test', //获取性能测试
  getalarminfo = '/statistics/get_alarm_info', //总览-获取报警量
  getdeviceinfo = '/statistics/get_device_info', //总览-获取设备信息
}

// 总览-获取设备信息
export const getdeviceinfo = () => defHttp.get({ url: Api.getdeviceinfo });
// 总览-获取报警量
export const getalarminfo = () => defHttp.get({ url: Api.getalarminfo });
// 获取性能测试
export const inserttest = () => defHttp.post({ url: Api.inserttest });
// 获取硬件信息
export const hardwareinfo = () => defHttp.get({ url: Api.hardwareinfo });
// 查询驱动详情
export const singleDrive = (params) => defHttp.get({ url: Api.singleDrive, params });
// 创建物模型和驱动
export const creatmodelDrive = (params) => defHttp.post({ url: Api.creatmodelDrive, params });
// 更新物模型和驱动
export const updatemodelDrive = (params) => defHttp.post({ url: Api.updatemodelDrive, params });
// 获取标准驱动
export const getstanddrive = (params) => defHttp.get({ url: Api.getstanddrive, params });
// 获取自定义驱动
export const getgatewaydrive = (params) => defHttp.get({ url: Api.getgatewaydrive, params });
// 重启网关
export const resetgateway = (params) => defHttp.post({ url: Api.resetgateway, params });
// 更新系统配置
export const updateconfig = (params) => defHttp.put({ url: Api.updateconfig, params });
// 系统配置列表
export const configoptionlist = (params) => defHttp.get({ url: Api.configoptionlist, params });
// 查询设备离线日志
export const queryofflog = (params) => defHttp.get({ url: Api.queryofflog, params });

// 查询属性数据
export const attributedata = (params) => defHttp.get({ url: Api.attributedata, params });
// 过去20天报警推送次数
export const alarmcount = () => defHttp.get({ url: Api.alarmcount });
// 查询设备详情
export const devicequerydevice = (params) => defHttp.get({ url: Api.devicequerydevice, params });
// 查询流量趋势
export const flowtrend = () => defHttp.get({ url: Api.flowtrend });
// 查询网关总览
export const gatewayoverview = () => defHttp.get({ url: Api.gatewayoverview });
// 查询物模型数据
export const deviceModedata = (params) => defHttp.get({ url: Api.deviceModedata, params });
// 查询设备云状态列表
export const getDriveLog = (params) => defHttp.get({ url: Api.getDriveLog, params });
// 自定义同步设备
export const customsyncdevice = (data) => defHttp.post({ url: Api.customsyncdevice, data });
//更新云服务启用状态
export const serviceEnableStatus = (data: serviceEnableStatusModel) =>
  defHttp.patch({ url: Api.serviceEnableStatus, data });
// 查询物模型云状态列表
export const modecloudinfoList = (params) => defHttp.get({ url: Api.modecloudinfoList, params });
// 同步物模型
export const synmodel = (data) => defHttp.post({ url: Api.synmodel, data });
// 查询设备云状态列表
export const devicecloudList = (params) => defHttp.get({ url: Api.devicecloudList, params });
// 同步设备
export const syndeviceinfo = (data) => defHttp.post({ url: Api.syndeviceinfo, data });
// 物模型属性导入模板下载
export const getdrive_by_modeid = (params) => defHttp.get({ url: Api.GETDRIVEBYMODEID, params });
// 物模型属性导入模板下载
export const attrtemplatedown = (params) => defHttp.get({ url: Api.ATTRTLTEDOWN, params });
// 导入物模型属性
export const importModelattrbute = (formData) =>
  defHttp.uploadFile({ url: Api.IMPORT_MODEL_ATTRIBUTE }, formData);
// 设置默认驱动
export const Setdefaultdrive = (data?: SetdefaultdriveModel) =>
  defHttp.post({ url: Api.SET_DEFAULT_DEVICE_TYPE, data });
// 上传驱动
export const uploaddrive = (formData) =>
  defHttp.uploadFile({ url: Api.UPLOAD_GATEWAY_DRIVE }, formData);
// 下载驱动
export const downloaddrive = () => defHttp.get({ url: Api.DOWNLOAD_GATEWAY_DRIVE });
// 删除驱动
export const delDrive = (data?: DriveModel) =>
  defHttp.post({ url: Api.DELETE_GATEWAY_DRIVE, data });
// 添加型号
export const AddModel = (data?: DeviceTypeModel) =>
  defHttp.post({ url: Api.CREAT_GATEWAY_DEVICE_TYPE, data });
// 编辑型号
export const editeModel = (data?: DeviceTypeModel) =>
  defHttp.post({ url: Api.UPDATE_GATEWAY_DEVICE_TYPE, data });
// 删除型号
export const delModel = (data) => defHttp.post({ url: Api.DELETE_GATEWAY_DEVICE_TYPE, data });
// 根据 品牌商ID 查询 关联型号
export const getDeviceTypeListApi = (params?: comQueryParams) =>
  defHttp.get<DeviceTypeModel[]>({ url: Api.GET_DEVICE_TYPE, params });
// 获取所有品牌商
export const getBarndListApi = () => defHttp.get<BrandModel[]>({ url: Api.GET_BRANDS });
// 查询驱动列表
export const getDriveList = (params?: drivePageParams) =>
  defHttp.get<drivePageParams[]>({ url: Api.GET_DRIVE_LIST, params });
// 根据 ID 查询品牌商
export const getBarndApi = (params?: comQueryParams) =>
  defHttp.get<BrandModel[]>({ url: Api.GET_BRAND_BYID, params });
// 查询物模型属性组
export const getDeviceModeAttrGroupApi = (params?: comPageQueryParams) =>
  defHttp.get<DeviceTypeModel[]>({ url: Api.GET_DEVICE_MODE_ATTR_GROUP, params });
// 查询物模型列表
export const getDeviceModeList = (params?: any) =>
  defHttp.get<comPageParams[]>({ url: Api.GET_MODEl_LIST, params });
// 添加物模型
export const getAddDeviceMode = (data?: DeviceTypeModel) =>
  defHttp.post({ url: Api.ADD_DEVICE_MODE, data });
// 编辑物模型
export const getUpdateDeviceMode = (data?: DeviceTypeModel) =>
  defHttp.post({ url: Api.UPDATE_DEVICE_MODE, data });
// 删除物模型
export const getDeleteDeviceMode = (data?: comQueryParams) =>
  defHttp.post({ url: Api.DELETE_DEVICE_MODE, data });
// 添加物模型组：
export const getAddModelGroup = (data?: ModelGroup) =>
  defHttp.post({ url: Api.ADD_MODEL_GROUP, data });
// 编辑物模型组
export const UpdateModelGoup = (data?: ModelGroup) =>
  defHttp.post({ url: Api.UPDATE_MODEL_GROUP, data });
// 获取物模型组
export const getModelGroupList = (params) =>
  defHttp.get<any[]>({ url: Api.GET_MODEL_GROUP, params });
// 删除物模型组
export const delAddModelGroup = (data?: DelModelGroup) =>
  defHttp.post({ url: Api.DEL_MODEL_GROUP, data });
// 新增物模型属性
export const addModelAttrList = (data?: AddModelAttr) =>
  defHttp.post({ url: Api.ADD_MODEL_ATTRIBUTE, data });
// 修改物模型属性
export const modifyModelAttrList = (data?: ModfiyModelAttr) =>
  defHttp.post({ url: Api.UPDATE_MODEL_ATTRIBUTE, data });
// 查询物模型属性
export const getModelAttrList = (params?: QueryModelAttr) =>
  defHttp.get<QueryModelAttr[]>({ url: Api.GET_MODEL_ATTRIBUTE, params });
// 删除物模型属性
export const delModelAttrList = (data?: DelModelGroup) =>
  defHttp.post({ url: Api.DEL_MODEL_ATTRIBUTE, data });

// 新增主设备
export const AddMainEquipmentList = (data?: any) =>
  defHttp.post({ url: Api.ADD_MAIN_EQUIPMENT, data });
// 修改主设备
export const ModifyMainEquipmentList = (data?: any) =>
  defHttp.post({ url: Api.UPDATE_MAIN_EQUIPMENT, data });
// 获取主设备
export const GetMainEquipmentList = (params?: any) =>
  defHttp.get<any[]>({ url: Api.GET_MAIN_EQUIPMENT, params });

// 获一个设备详情
export const GetMainEquipmentDetail = (params?: any) =>
  defHttp.get<any[]>({ url: Api.GET_MAIN_ONEEQUIPMENT, params });
// 删除主设备
export const DelMainEquipmentList = (data?: any) =>
  defHttp.post({ url: Api.DEl_MAIN_EQUIPMENT, data });

// 获取未被组合的子设备
export const GetNonEquipmentList = (params?: any) =>
  defHttp.get<any[]>({ url: Api.GET_NON_EQUIPMENT, params });

// 新增子设备
export const AddEquipmentList = (data?: AddEquipment) =>
  defHttp.post({ url: Api.ADD_EQUIPMENT, data });
// 修改子设备
export const ModifyEquipmentList = (data?: ModifyEquipment) =>
  defHttp.post({ url: Api.UPDATE_EQUIPMENT, data });
// 获取子设备
export const GetEquipmentList = (params?: GetEquipment) =>
  defHttp.get<GetEquipment[]>({ url: Api.GET_EQUIPMENT, params });
// 删除子设备
export const DelEquipmentList = (data?: DelModelGroup) =>
  defHttp.post({ url: Api.DEl_EQUIPMENT, data });

// 查询物模型属性
export const querydatalog = (params?: selectdatalog) =>
  defHttp.get({ url: Api.QUERYDATALOG, params });
// 云服务
export const addServiceApi = (data: ServiceModel) =>
  defHttp.post({ url: Api.ADD_UPDATE_DELETE_SERVICE, data });
export const editServiceApi = (data: ServiceModel) =>
  defHttp.patch<ServiceModel[]>({ url: Api.ADD_UPDATE_DELETE_SERVICE, data });
export const getServiceApiByID = (params) =>
  defHttp.get({ url: Api.ADD_UPDATE_DELETE_SERVICE, params });
export const deleteServiceApi = (data: ServiceModel) =>
  defHttp.delete<ServiceModel[]>({ url: Api.ADD_UPDATE_DELETE_SERVICE, data });
export const getServiceListByPage = (params?: ServicePageParams) =>
  defHttp.get<ServicePageListGetResultModel>({ url: Api.GET_SERVICE_LIST, params });
//验证链接
export const test_push = () => defHttp.get({ url: Api.TESSTPUSH });
//获取推送配置
export const getpushconfig = () => defHttp.get<pushconfig[]>({ url: Api.PUTCONFIG });
//设置推送
export const setpushconfig = (data: pushConfigModel) => defHttp.post({ url: Api.PUTCONFIG, data });
